import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CategoryVo, CategoryForm, CategoryQuery } from './types';

//列表 category
export const getListCategory = (query: CategoryQuery): AxiosPromise<CategoryVo[]> => {
  return request({
    url: '/lawyer/category/list',
    method: 'get',
    params: query
  });
};

//添加 category
export const saveCategory = (data: CategoryForm) => {
  return request({
    url: '/lawyer/category/saveCategory',
    method: 'post',
    headers: {
      repeatSubmit: false
    },
    data: data
  });
};

//修改 category
export const updateCategory = (data: CategoryForm) => {
  return request({
    url: '/lawyer/category/updateCategory',
    method: 'post',
    headers: {
      repeatSubmit: false
    },
    data: data
  });
};

//删除 category
export const removeCategory = (id: string | number | Array<string | number>) => {
  return request({
    url: '/lawyer/category/' + id,
    method: 'delete'
  });
};

//获取 category
export const getCategory = (id: string | number): AxiosPromise<CategoryVo> => {
  return request({
    url: '/lawyer/category/' + id,
    method: 'get'
  });
};

/**
 * 查询分类下拉树结构
 */
export const getCategoryTreeSelect = (): AxiosPromise<CategoryVo[]> => {
  return request({
    url: '/lawyer/category/categoryTree',
    method: 'get'
  });
};
